package com.elong.businesstravel.modules.home.widget;

import com.android.support.jhf.utils.InputMethodUtils;
import com.elong.businesstravel.modules.home.HotelCitySelectActivity;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.inputmethod.InputMethodManager;
import android.widget.AutoCompleteTextView;

public class CitySearchAutoCompleteTextView extends AutoCompleteTextView {
	
	private Context mContext;

	public CitySearchAutoCompleteTextView(Context context) {
		super(context);
		init(context);
	}

	public CitySearchAutoCompleteTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}

	public CitySearchAutoCompleteTextView(Context context, AttributeSet attrs,
			int defStyle) {
		super(context, attrs, defStyle);
		init(context);
	}
	
	private void init(Context context) {
		mContext = context;
	}

	@Override
	public boolean onKeyPreIme(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK){
			
			if (InputMethodUtils.hideSoftKeyboard(mContext,
					this)) {
				
			} else {
				return super.onKeyPreIme(keyCode, event);
			}
			
			return true;
		}
		return super.onKeyPreIme(keyCode, event);
	}
	
	
}
